<?php

class Crud_Form_Element_Many2many_Tree extends Crud_Form_Element_Many2many
{
	/**
	 * Setup decorators for element.
	 * 
	 * @return void
	 */
	protected function _initDecorators()
	{
		$this->_addTreeDecorator();
	}
	
	/**
	 * Adding Tree decorator.
	 * 
	 * @return void
	 */
	protected function _addTreeDecorator()
	{
		$table = $this->getTable();
		$m2mTable = $this->getM2mTable();
		$column3rd = $m2mTable->getFKColumnNotFor($table);
		$tree = $column3rd->getFKValuesAsTree();
		
		$decorator = new Crud_Form_Decorator_Tree();
		$decorator->setTree($tree);
		
		$this->_addDecoratorAfterViewHelper($decorator);
	}
}

